package pong.game.objects;

import java.util.Vector;

import pong.game.WifiType;
import pong.general.GameWindow;

import android.graphics.Bitmap;

public class Handle extends Rectangle
{
	private static final float	slowness = 0.01f;
	
	public Handle(Bitmap handle)
	{
		super(handle);
	}
	public Handle(Bitmap handle, WifiType wifiType, float X, float Y, float height, float width)
	{
		super(handle, wifiType, X, Y, height, width);
	}
	public Handle(Bitmap handle, WifiType wifiType, float X, float Y)
	{
		super(handle, wifiType, X, Y, (float)handle.getHeight() / GameWindow.heightWorld,
				(float)handle.getWidth() / GameWindow.widthWorld);
	}
	void 			slow()
	{
		dir.multy(slowness);
	}
	boolean 		leaveGameZone(Vector<DinamicObject> GameObjects)
    {
        return pos.x < 0 || pos.x + width > 1.0f;
    }	
	void			addPosition(Vector<DinamicObject> GameObjects)
	{
		dir.y = 0;
		pos.add(dir);
		if (leaveGameZone(GameObjects) || isConflict(GameObjects))
        {
			if(pos.x <= 0)
			{
				dir.minus(dir);
				pos.x = 0;
				return;
			}
			if(pos.x + width >= 1.0f)
			{
				dir.minus(dir);
				pos.x = 1.0f - width;
				return;
			}
			pos.minus(dir);
			pos.minus(dir);
			
			addPosition(GameObjects);
        }
	}
}
